import 'package:enjoy_plus/models/home_nav_model.dart';
import 'package:enjoy_plus/utils/toast.dart';
import 'package:flutter/material.dart';

class HomeNav extends StatelessWidget {
  HomeNav({super.key});

  // 导航栏数据
  final List<NavItem> navItemList = [
    const NavItem(
      title: '我的房屋',
      icon: 'assets/images/house_nav_icon@2x.png',
      route: '/houseList',
    ),
    const NavItem(
      title: '我的报修',
      icon: 'assets/images/repair_nav_icon@2x.png',
      route: '/myRepairList',
    ),
    const NavItem(
      title: '访客登记',
      icon: 'assets/images/visitor_nav_icon@2x.png',
      route: '/visitorList',
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(top: 10, bottom: 10),
      padding: const EdgeInsets.only(top: 10, bottom: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: navItemList
            .map((item) => Expanded(
                  child: InkWell(
                    onTap: () {
                      Navigator.pushNamed(context, item.route);
                    },
                    child: Column(
                      children: [
                        Image.asset(
                          item.icon,
                          width: 35,
                        ),
                        Text(item.title),
                      ],
                    ),
                  ),
                ))
            .toList(),
      ),
    );
  }
}
